#!/bin/bash

cat<<INCLUDES
#include "server.h"
#include "trampolines.h"

INCLUDES

symbols=""
is_extern=1
while read line; do
    for word in $line; do
        if [ $word = "--" ]; then
            is_extern=0
            continue
        fi
        if (( $is_extern )); then
            if [[ $word != "strcmp" && $word != "strlen" ]]; then
                printf "void $word();\n"
            fi
        fi
        symbols="$symbols $word"
    done
done

printf "\n"
printf "__symbol_t symbols[] = {"

conn=""
for symbol in $symbols; do
    printf "$conn\n  {\"$symbol\",(void(*)())$symbol}"
    conn=","
done

printf "\n"
printf "};\n"
